﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;

namespace StudentManagement.ViewModel
{
    /// <summary>
    /// 视图模型实体基类
    /// </summary>
    public abstract class VMbase : INotifyPropertyChanged
    {
        // Declare the event
        public event PropertyChangedEventHandler PropertyChanged;


        // Create the OnPropertyChanged method to raise the event
        // The calling member's name will be used as the parameter.
        //protected void OnPropertyChanged([CallerMemberName]string name = null)
        //{
        //    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        //}


        /// <summary>
        /// 设置控件中的值。使用方法 set { _code = value; VmSet(nameof(Code)); }
        /// </summary>
        /// <param name="propertyName"></param>
        protected void VmSet(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
